package practice1_100;

import com.sun.source.tree.CaseTree;

import javax.swing.plaf.synth.SynthTextAreaUI;
import java.lang.reflect.Array;
import java.util.*;

public class Practice4 {
    public double findMedianSortedArrays(int[] nums1, int[] nums2) {

        int length1 = 0;
        int length2 = 0;
        int[] mergeArray = new int[nums1.length + nums2.length];
        //对数组进行一个合并
        int i = 0;
        for (; i < mergeArray.length && length1 < nums1.length && length2 < nums2.length; i++) {
            mergeArray[i] = nums1[length1] > nums2[length2] ? nums2[length2] : nums1[length1];
            if (nums1[length1] > nums2[length2]) length2++;
            else length1++;
        }
        while (length1 < nums1.length) {
            mergeArray[i++] = nums1[length1++];
        }
        while (length2 < nums2.length) {
            mergeArray[i++] = nums2[length2++];
        }
        if (mergeArray.length % 2 == 0) {
            return (mergeArray[mergeArray.length / 2 - 1] + mergeArray[mergeArray.length / 2]) / 2.0;
        } else {
            return mergeArray[mergeArray.length / 2];
        }
    }

//    public static void main(String[] args) {
////        Scanner scanner=new Scanner(System.in);
////        //第一行输入
////        String line1=scanner.nextLine();
////        String[] lines=line1.split(" ");
////        int[] temp=new int[lines.length];
////        for (int i=0;i<temp.length;i++)
////            temp[i]=Integer.parseInt(lines[i]);
////        int[][] matrix=new int[temp[0]][temp[1]];
////        int x=temp[2],y=temp[3];
////        //接受矩形输入
////        int col=0;
////        while (scanner.hasNext()&&col<temp[0]){
////            String mat=scanner.nextLine();
////            String mats[]=mat.split(" ");
////            for (int i = 0; i < mats.length; i++) {
////                matrix[col][i]=Integer.parseInt(mats[i]);
////            }
////            col++;
////        }
////        //最后一行输入
////        String paths[]=scanner.nextLine().split("");
////        int rowStart=0, colStart =0,res=0,direct=0;
////        for (int i = 0; i < paths.length; i++) {
////            if(paths[i].equals("h")){//左,1
////                if(colStart-1>=0&&matrix[rowStart][colStart-1]!=-1){//不存在阻力
////                    if(direct==0) res=res+matrix[rowStart][colStart-1];//刚开始
////                    else if(direct!=1) res=res+x+Math.max(matrix[rowStart][colStart-1],matrix[rowStart][colStart]);//不向左
////                    else res=res+Math.max(matrix[rowStart][colStart-1],matrix[rowStart][colStart]);//向左
////                    direct=1;
////                    colStart--;
////                }else {//存在阻力,原地不动
////                    if(direct==0||direct==1)res+=y;
////                    else res+=y+x;
////                    direct=1;
////                }
////            }else if(paths[i].equals("j")){//下,2
////                if(rowStart+1< matrix.length&&matrix[rowStart+1][colStart]!=-1){//不存在阻力
////                    if(direct==0) res=res+matrix[rowStart+1][colStart];//刚开始
////                    else if(direct!=2) res=res+x+Math.max(matrix[rowStart+1][colStart],matrix[rowStart][colStart]);//不向左
////                    else res=res+Math.max(matrix[rowStart+1][colStart],matrix[rowStart][colStart]);//向左
////                    direct=2;
////                    rowStart++;
////                }else {//存在阻力,原地不动
////                    if(direct==0||direct==2)res+=y;
////                    else res+=y+x;
////                    direct=2;
////                }
////            }else if(paths[i].equals("k")){//上,3
////                if(rowStart-1>=0&&matrix[rowStart-1][colStart]!=-1){//不存在阻力
////                    if(direct==0) res=res+matrix[rowStart-1][colStart];//刚开始
////                    else if(direct!=3) res=res+x+Math.max(matrix[rowStart-1][colStart],matrix[rowStart][colStart]);//不向左
////                    else res=res+Math.max(matrix[rowStart-1][colStart],matrix[rowStart][colStart]);//向左
////                    direct=3;
////                    rowStart--;
////                }else {//存在阻力,原地不动
////                    if(direct==0||direct==3)res+=y;
////                    else res+=y+x;
////                    direct=3;
////                }
////            }else{//右,4
////                if(colStart+1< matrix[0].length&&matrix[rowStart][colStart+1]!=-1){//不存在阻力
////                    if(direct==0) res=res+matrix[rowStart][colStart+1];//刚开始
////                    else if(direct!=4) res=res+x+Math.max(matrix[rowStart][colStart+1],matrix[rowStart][colStart]);//不向左
////                    else res=res+Math.max(matrix[rowStart][colStart+1],matrix[rowStart][colStart]);//向左
////                    direct=4;
////                    colStart++;
////                }else {//存在阻力,原地不动
////                    if(direct==0||direct==4)res+=y;
////                    else res+=y+x;
////                    direct=4;
////                }
////            }
////        }
////        System.out.println(res);
//        List<List<Integer>> list=new Practice4().back(new int[]{1,2,4,5,6,7,9});
//        System.out.println(list);
//    }

    static long Convert(double f,int n){
        long temp=(long)Math.pow(10,n);
        return (long)f*temp;
    }

    //回溯法框架
    public  List<List<Integer>> back(int[] ints){
        List<List<Integer>> res=new LinkedList<>();
        LinkedList<Integer> temp=new LinkedList<>();
        backPath(ints,res,temp);
        System.out.println(res.size());
        return res;
    }

    private void backPath(int[] ints, List<List<Integer>> res,LinkedList<Integer> temp) {
        //边界值
        if(temp.size()==ints.length) res.add(new LinkedList(temp));
        //选择
        for (int i = 0; i <ints.length ; i++) {
            if(temp.contains(ints[i]))continue;
            temp.add(ints[i]);
            backPath(ints,res,temp);
            temp.removeLast();//撤销选择
        }
    }

    private Practice4(){}
    public volatile static   Practice4 practice4=null;
    public  static  Practice4  getInstance(){
        if(practice4==null){
            synchronized (Practice4.class){
                if(practice4==null) practice4=new Practice4();
                return practice4;
            }
        }
        return practice4;
    }

    public static   int[] minimumNumber(int[] target){
        int[] res=new int[target.length];
        int[] score=new int[]{1,2,3,4};
        int maxvalue=0;//找出最大值
        for (int i = 0; i < target.length; i++) {
            maxvalue=maxvalue>target[i]?maxvalue:target[i];
        }
        //生成一个数组
        int[] temp=new int[maxvalue-10+1];
        Arrays.fill(temp,Integer.MAX_VALUE);
        temp[1]=1;temp[2]=1;temp[3]=1;temp[4]=1;
        for (int i = 5; i < temp.length; i++) {
            for (int j = 1; j <= 4; j++) {
                temp[i]=temp[i]>temp[i-j]+1?temp[i-j]+1:temp[i];
            }
        }
        for (int i = 0; i < res.length; i++) {
            if(target[i]-10<0)res[i]=-1;
            else if(target[i]-10==0)res[i]=4;
            else {
                res[i]=temp[target[i]-10]+4;
            }
        }
        return res;
    }

    public  int happy(int[] edges){
        Arrays.sort(edges);
        if(edges.length==3&&edges[0]+edges[1]>edges[2])return 1;
        else if(edges.length==3&&edges[0]+edges[1]<edges[2] ||edges.length<3)return 0;
        int count=0;
        for (int i = edges.length - 1; i >= 2; i--) {
            int left = 0, right = i - 1;
            while(left < right) {
                if (edges[left] + edges[right] > edges[i]&&
                        (edges[left]!=edges[i]&&edges[i]!=edges[right])&&
                        ((int)Math.pow(edges[left],2)+(int)Math.pow(edges[i],2)!=(int)Math.pow(edges[right],2))){
                    count += (right - left);
                    right--;
                }
                else {
                    left++;
                }
            }
        }
        return count;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] temp = sc.nextLine().split(" ");
        int len=Integer.parseInt(temp[0]);
        int niuniuLoc=Integer.parseInt(temp[1])+1;
        String[] padding = sc.nextLine().split(" ");
        int[] pad=new int[padding.length];
        for(int i=0;i<padding.length;i++)pad[i]=Integer.parseInt(padding[i]);//队伍

        HashMap<Integer,Integer> map=new HashMap<>();
        for (int i=1;i<=len;i++){
            map.put(i,0);
        }
        int[] res=new int[niuniuLoc-1];
        //队伍移动,第一步移动3人,除i第一名外三人要前移，第二步移动3人，除第二名外三人要前移动
        for(int i=1;i<niuniuLoc;i++){
            int resnoe=0;
            for (int j = i+1; j <i+1+pad[i-1] ; j++) {
                if(map.containsKey(j)){
                    map.put(j,map.get(j)+1);
                    resnoe+=1;
                }
            }
            res[i-1]=resnoe;
        }
        System.out.println(res);

    }
}
